package cn.bigcontainer.alt.b2c.be.controller;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import cn.bigcontainer.alt.b2c.be.dto.B2cShangpinfenleiDto;
import cn.bigcontainer.alt.common.exception.BigResultCode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import cn.bigcontainer.alt.b2c.be.service.B2cShangpinfenleiService;
import cn.bigcontainer.alt.sys.util.SysConstant;

/**
 * 商品分类的Controller类，用于处理用户请求.
 *
 * @author jiaod
 * @date 2020-05-18
 */
@Controller
@SessionAttributes(SysConstant.SESSION_USER)
@RequestMapping("/b2c/shangpinfenlei")
public class B2cShangpinfenleiController {

	@Resource
	private B2cShangpinfenleiService b2cShangpinfenleiService;

	@RequestMapping("")
	public String toMain(@RequestParam Map<String, Object> req, Map<String, Object> map) {
		return "b2c/shangpinfenlei/index";
	}

	@RequestMapping(value = "/getLever")
	@ResponseBody
	public BigResultCode getLever(@RequestParam Map<String, Object> req, Map<String, Object> map) {
		List<B2cShangpinfenleiDto> events= b2cShangpinfenleiService.getLever((String) req.get("bh"));
		return BigResultCode.getSuccessCode().setContent(events);
	}

	@RequestMapping(value = "/getForm")
	@ResponseBody
	public BigResultCode getForm(@RequestParam Map<String, Object> req, Map<String, Object> map) {
		List<B2cShangpinfenleiDto> events= b2cShangpinfenleiService.getForm((String) req.get("bh"));
		return BigResultCode.getSuccessCode().setContent(events);
	}

	@RequestMapping(value = "/saveForm")
	@ResponseBody
	public Object saveForm(@RequestParam Map<String, Object> req, Map<String, Object> map) throws ParseException {
		int events= b2cShangpinfenleiService.saveForm(req);
		return events;
	}

	@RequestMapping(value = "/delForm")
	@ResponseBody
	public Object delForm(@RequestParam Map<String, Object> req, Map<String, Object> map) throws ParseException {
		int events= b2cShangpinfenleiService.delForm(req);
		return events;
	}

}
